package com.example.wechat.wechat;



import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.*;
import java.util.*;



public class ContentFragment_WeChat extends Fragment {

    private List<ChatItem> chatItemList = new ArrayList<>();

    public ContentFragment_WeChat() {
        // Required empty public constructor
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initChatItems();


    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.content_fragment__we_chat, container, false);
        RecyclerView recyclerView = view.findViewById(R.id.Chat_view);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(linearLayoutManager);


        ChatItemAdapter adapter = new ChatItemAdapter(getActivity(),chatItemList);
        recyclerView.setAdapter(adapter);

        return view;
    }

    private void initChatItems() {
        for (int i = 0; i < 3; i++) {
            ChatItem apple = new ChatItem("apple", R.drawable.contact_pressed ,"1111");
            chatItemList.add(apple);
            ChatItem banana = new ChatItem("banana", R.drawable.contact_pressed,"222");
            chatItemList.add(banana);
            ChatItem pear = new ChatItem("pear", R.drawable.contact_pressed,"3333");
            chatItemList.add(pear);
        }


    }
}
